/*
 * Project: D-Link TR-069
 * 
 * File:   data.h
 * 
 * Authors: Taron Sargsyan <taronhsargsyan@gmail.com>		
 * 	    Suren Gharagyozyan	
 *
 * Created on September 20, 2011, 11:53 AM
 * 
 * 
 * This object is useful to parsing XML files e.g.
 * Parse XML files(requests)  which recieved from tr069 client.  
 * 
 * Copyright (C) 2011 D-Link Company.  All rights reserved.
 */

#ifndef _PARSER_H_
#define _PARSER_H_

#define NOT_FOUND -1
#define GET_MODEL_VALUE_STR_SIZE 128
#define XMLfILE_MSG_SIZE 50000

typedef struct getValue{
  char getValueStr[128];
}getParamValues[GET_MODEL_VALUE_STR_SIZE];


typedef struct getName{
  char getNameStr[128];
}getParamNames[GET_MODEL_VALUE_STR_SIZE];

typedef struct fileBuff
{
  char fileContBuff[XMLfILE_MSG_SIZE];
  getParamValues get_val;
  getParamNames get_names;
  
}fileContBuffStruct[1025];

extern fileContBuffStruct fileCBuff;


struct string {
	char str[512];
}mystring[4];

typedef struct getNewVal{
    char getNewValue[256];
}getNewParamValues[GET_MODEL_VALUE_STR_SIZE];

char ret_tag_el_val[XMLfILE_MSG_SIZE]; 
char ret_get_tag_val[4096];
char reade_file_buffer[512];
int strSz;
int number_of_values;
int number_of_names;
extern int noSqlError;

char* readFileByTag(const char *fileName, char* tag_name);
char* getTags(char *fContent, char* tag,int pos);
int find_string (char* str, char* sub, int pos );
char* substring(char* from, char* to, int start, int end);
char* stripTag(char* str,const char* tag);
void tokenization(char strContent[], char cSep[]);
char* toUpperCase(char* str);
char* fileRead(const char* fName);
void initDBaseParameters(const char* fName, char* server, char* user, char* password, char* database);
char* getTagElems(char*,const char*);
void getValues( getParamValues,char*); 
void getNames(getParamNames,char*);
int get_index(getParamNames,char*);
char* strip( char* str, char* tag);

void set_get_value_db( getParamNames get_names,getParamValues get_val,getNewParamValues,char*,char* );
void parameterFilter(getParamNames get_names,getParamValues get_val,getNewParamValues,char*);

#endif
